<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- // 猜数字游戏，设定次数，最多猜8次 -->
    <script>
        let x = Math.floor(Math.random() * 100)
        for (i = 0; i <= 8; i++) {
            let y = prompt('猜数字')


            if (x > y) {
                alert("小")
            }

            else if (x < y) {
                alert("大")
            } else if (x == y) {
                alert("对")
                break
            }
        }
        console.log(`${x}`);
    </script>
</body>

</html>